package net.wofly.sale.commodity.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import net.wofly.framework.dao.BaseRepository;
import net.wofly.sale.commodity.domain.Commodity;
import net.wofly.sale.commodity.domain.CommodityTerminal;

public interface CommodityTmlRepository extends BaseRepository<CommodityTerminal, String>{
    
    CommodityTerminal findByCommodityIDAndCommodityTerminalTypeAndStatus(String commodityID, Integer commodityTerminalType, Integer status);

    @Query(value = "select c from Commodity c , CommodityTerminal ct where c.commodityID = ct.commodityID and commodityTerminalID like :commodityTerminalID%")
	public Commodity findCommodityByCommodityTerminalID(@Param("commodityTerminalID") String commodityTerminalID);
    
    public Page<CommodityTerminal> findByStatusAndHasCommodityTerminal(@Param("status") Integer status ,@Param("hasCommodityTerminal") Integer hasCommodityTerminal , Pageable pageable);
    
    @Query(value = "from CommodityTerminal c where c.commodityID = :commodityID order by commodityTerminalType asc")
    public List<CommodityTerminal> findByCommodityID(@Param("commodityID")String commodityID) ;
}
